/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.sdkj.dspservice.modules.gen.entity;

import com.sdkj.dspservice.common.base.entity.DataEntity;
import com.sdkj.dspservice.common.constant.Punctuation;
import com.sdkj.dspservice.common.utils.StringUtils;
import lombok.Data;

import javax.xml.bind.annotation.XmlTransient;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 生成方案Entity
 * @author tm
 * @version 2020-11-23
 */
//@XmlRootElement(name="template")
@Data
public class Template extends DataEntity<Template> {

	/**
	 * 名称
	 */
	private String name;
	/**
	 * 分类
	 */
	private String category;
	/**
	 * 生成文件路径
	 */
	private String filePath;
	/**
	 * 文件名
	 */
	private String fileName;
	/**
	 * 内容
	 */
	private String content;

	public Template() {
		super();
	}

	public Template(String id){
		super(id);
	}
	
	@XmlTransient
	public List<String> getCategoryList() {
		if (category == null){
			return new ArrayList<>();
		}else{
			return new ArrayList<String>(){{addAll(Arrays.asList(StringUtils.split(category, Punctuation.COMMA)));}};
		}
	}

	public void setCategoryList(List<String> categoryList) {
		if (categoryList == null){
			this.category = "";
		}else{
			this.category = Punctuation.COMMA+StringUtils.join(categoryList, Punctuation.COMMA) + Punctuation.COMMA;
		}
	}
	
}


